package com.fanrenqiji.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * Created by yanwt on 2017/1/3.
 * 家长信息表
 */
@Getter
@Setter
@Entity
@Table(name = "tb_parent")
@org.hibernate.annotations.Table(appliesTo = "tb_parent",comment = "家长信息表")
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate
@org.hibernate.annotations.Cache(region="parent", usage = CacheConcurrencyStrategy.READ_WRITE)
public class ParentEntity extends DataEntity implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    @Column(columnDefinition=("varchar(100) default null comment '家长姓名'"))
    private String name;
    @Column(columnDefinition=("varchar(20) default null comment '联系电话'"))
    private String phone;
    @Column(columnDefinition = ("varchar(200) default null comment '头像'"))
    private String portrait;
    @Column(columnDefinition=("varchar(50) default null comment '密码'"))
    private String password;
    @Column(name = "identification_code", columnDefinition = ("varchar(50) default null comment '身份证号码'"))
    private String identificationCode;
    @Column(name = "sex", columnDefinition = ("int not null comment '性别 0:女 1:男'"))
    private String sex;
    @Column(name="area_id",columnDefinition = ("bigint(20) not null comment '地区ID 从系统地区表选择'"))
    private Long areaId;
    @Column(name = "address", columnDefinition = ("varchar(255) default null comment '家庭住址'"))
    private String address;
    @Column(columnDefinition=("varchar(50) default null comment '来源'"))
    private String source;
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "company_id", insertable = false, updatable = false, columnDefinition = ("bigint(20) default null comment '公司ID'"))
    @Where(clause = "del_flag=" + DEL_FLAG_NORMAL)
    private OfficeEntity office;

    @Column(name = "company_id", columnDefinition = ("bigint(20) not null comment '公司ID'"))
    private Long companyId;
    @Column(columnDefinition = ("int(1) not null comment '用户级别 0:未分级 1:E级 2:D级 3:C级 4:B级 5:A级 6:签单 7:退费'"))
    private int level;    //用户级别

    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name="we_chat_user_id",columnDefinition=("bigint(20) default null comment '微信用户ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private WeChatUserEntity weChatUser;
}
